//
//  SearchViewModel.m
//  DataStatistics
//
//  Created by Kang on 16/6/14.
//  Copyright © 2016年 YTYangK. All rights reserved.
//

#import "SearchViewModel.h"
#import "EquipmenModel.h"           // 设备模型
#import "RemoveBindingModel.h" // 删除模型

//#import "EquipmenDetailsVC.h"

@interface SearchViewModel()

@end

@implementation SearchViewModel
singleton_for_implementation(SearchViewModel)

#pragma mrak - 设备列表
+ (void)requestWithUrlForSearchIn:(id)obj andParam:(NSDictionary *)param
                          success:(void(^)(NSMutableArray *model))success failure:(void(^)(NSString *error))failure {
    
    MDC_INTER_DIC(@"app/deviceList.do", @"NetMethodPOST", @"false")
    
    [super initRequestWithUrlObj:obj parametersDic:param Interface:inter success:^(id obj, id model) {
        
        NSLog(@"%@",model);
        
        if ([model[@"body"][@"deviceDps"] count] == 0) {
            success(nil);

        }else{
            
            success(model[@"body"][@"deviceDps"]);
            
        }
    } failure:^(id obj, NSString *err) {
        failure(err); //返回是因为需要列表拉下来
    }];
}

     
     
#pragma mark - 删除绑定
+ (void)requestWithUrlForDeviceRemoveBinding:(id)obj andParam:(NSDictionary *)param success:(void(^)(RemoveBindingModel *model))success failure:(void(^)(NSString * error))failure {
    
    MDC_INTER_DIC(@"app/unbindDevice.do", @"NetMethodPOST", @"false")
    [super initRequestWithUrlObj:obj parametersDic:param Interface:inter success:^(id obj, id model) {
        
        NSLog(@"%@",model);
        
        
        
        
        if ([model[@"status"]intValue] == 1) {
            success(model);
        }else {
            failure(NSLocalizedString(@"SysLead_Delete", nil));
        }

    
    } failure:^(id obj, NSString *err) {
        [MBProgressHUD showError:err]; //返回是因为需要列表拉下来
    }];
}







@end
